package com.xfs.user.entity.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @Author dwj
 * @Date 2021-10-15 20:02
 */
@Data
public class Result<T> {
    /**定义返回码*/
    private Integer code;
    /**返回描述*/
    private String message;
    /**返回数据*/
    private T data;
    /**分页查询总记录数*/
    private Long count;

    /**构造方法私有化*/
    private Result(){

    }
    private Result(Integer code, String message, T data, Long count) {
        this.code = code;
        this.message = message;
        this.data = data;
        this.count = count;
    }
    /**
     * 设定返回方法
     */
    public static Result<Object> success(){
        return new Result(0,"success",null,null);
    }

    public static Result<Object> success(Object data, Long count){
        return new Result(0,"success",data,count);
    }

    public static Result<Object> fail() {
        return new Result(-1,"fail",null,null);
    }
    public static Result<Object> fail(String message) {
        return new Result(-1,message,null,null);
    }

    public static Result<Object> success(String msg){
        return new Result(0,msg,null,null);
    }
}
